@extends('admin.home.main')

@section('body')
<section id="main-content">

<section class="wrapper">
<h3>活动列表</h3>
<hr>
<div class="row mt">
  <div class="col-md-12">
    <form action="/admin/activity/list" method="get">
      <select size="1" name="page_size" aria-controls="hidden-table-info" style="width:80px; height:34px; float:left; " class="form-control">
        <option value="0">请选择</option>
        @foreach($page_size_list as $ptm=>$pst)
          @if($pst == $page_size)
          <option value="{{$pst}}" selected="selected">{{$pst}}</option>
          @else
          <option value="{{$pst}}">{{$pst}}</option>
          @endif
        @endforeach
      </select>
      <input type="text" style="width:200px;float:left; margin-left:10px;" class="form-control" placeholder="请输入活动称" name="keywords" id="keywords" value="{{$keywords}}">
      <button type="submit" id="search" style="float:left; margin-left:10px;" class="btn btn-success">搜索</button>
    </form>
  </div>
</div>

<!-- row -->
<div class="row mt">
  <div class="col-md-12">
    <div class="content-panel">
      <table class="table table-striped table-advance table-hover">
        <thead>
          <tr>
          	<th>#</th>
            <th>活动名称</th>
            <th width="15%">活动简介</th>
            <th>活动封面</th>
            <th>活动起止时间</th>
            <th>活动地址</th>
            <th>价格</th>
            <th>报名人数</th>
            <th>课程状态</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          @foreach($activitylist as $atm=>$ast)
            <tr>
              <td>{{$ast->id}}</td>
              <td>{{$ast->name}}</td>
              <td>{{$ast->desc}}</td>
              <td><img src="{{$ast->thumb}}" style="width:100px;"></td>
              <td>{{$ast->start_date}}<br>{{$ast->end_date}}</td>
              <td>{{$ast->address}}</td>
              <td>{{$ast->price}}</td>
              <td>{{$ast->enrolment}}</td>
              <td>
                  @if($ast->status == 1)
                    报名中
                  @elseif($ast->status == 2)
                    已创建
                  @else
                    已完结
                  @endif
              </td>
              <td>
                <a href="/admin/activity/sign_user_list/{{$ast->id}}" class="btn btn-warning btn-xs">报名列表</a>
                <a href="/admin/activity/modify/{{$ast->id}}" class="btn btn-primary btn-xs" >编辑</a>
                <button type="button" colid="{{$ast->id}}" class="btn btn-danger btn-xs col_del">删除</button>
              </td>
            </tr>
          @endforeach
        </tbody>
      </table>
    </div>
    <!-- /content-panel -->
    <div class="row-fluid">

      <div class="span6">
        <div class="dataTables_paginate paging_bootstrap pagination">
          <ul>{!! $activitylist->render() !!}</ul>
        </div>
      </div>
    </div>
  </div>
  <!-- /col-md-12 -->
</div>
<!-- /row -->
</section>
</section>
<script type="text/javascript">
  $('.col_del').click(function(){
    var _colId = $(this).attr('colid');

    var a = confirm('请确认是否要删除该活动');
    var t = $(this).parent().parent();

    if(a == true){
      $.ajax({
        'type':'get',
        'url':'/admin/activity/del/'+_colId,
        'dataType':'json',
        success:function(msg){
          if(msg.code == 200){
            alert('删除成功');
          }else{
            alert('删除失败');
          }
          location.reload();
        }
      })
    }
  })
</script>
@endsection